<template>
  <Dialog title="人员开户" :loading="loading" :visible="visible" class="single-column" button-text="保存" @close="handleClose" @confirm="handleConfirm">
    <el-form ref="ruleForms" :model="ruleForm" :rules="rules" label-width="100px">
      <el-row flex>
        <el-col :span="24">
          <el-form-item label="账号：" prop="account">
            <el-input v-model="ruleForm.account" style="width: 235px;" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </Dialog>
</template>
<script>
import Dialog from "@/components/Dialog";
export default {
  components: { Dialog },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    currentRow: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      props: { multiple: true },
      ruleForm: {
      },
      rules: {
        usrName: [
          { required: true, message: '请输入名称', trigger: 'blur' },
        ],
      },
      loading: false,
    };
  },
  watch: {
    currentRow: {
      handler(val) {
        // this.ruleForm.usrId = val.id;
      },
      deep: true,
    },
  },
  mounted() {
    if (this.currentRow) {
      this.ruleForm.usrId = this.currentRow.id;
    }
  },
  methods: {
    handleClose() {
      this.$emit('update:visible', false);
      this.$emit('update:row', []);
      this.$refs.ruleForms.resetFields();
      this.ruleForm = { };
    },
    handleConfirm() {
      this.$refs.ruleForms.validate(async valid => {
        if (!valid) return;
        this.loading = true;
        const res = await this.$api['data/hospitalStaff/register']({ ...this.ruleForm });
        if (res.code !== 200) {
          this.loading = false;
          this.$message.error("开户失败");
          return;
        }
        this.$emit('success');
        this.$message.success("开户成功");
        this.handleClose();
        this.loading = false;
      });
    },
  },
};
</script>

<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 78px;
    height: 78px;
    line-height: 78px;
    text-align: center;
  }
  .avatar {
    width: 78px;
    height: 78px;
    display: block;
  }
  .font-style{
    line-height: 32px;
    margin-left: 20px;
    cursor: pointer;
  }
</style>
